#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int minimumSum(int num) {
    vector<int> nums;
    while (num)
    {
        nums.push_back(num % 10);
        num /= 10;
    }
    sort(nums.begin(), nums.end());
    return 10 * (nums[0] + nums[1]) + nums[2] + nums[3];
}